Passed
Pull Request — master (#87)
by Mathieu
01:31
created

CreatePayStubAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 22
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index 0 13 2
1
import {
2
  Body,
3
  Post,
4
  Controller,
5
  Inject,
6
  BadRequestException,
7
  UseGuards,
8
  UploadedFile,
9
  UseInterceptors
10
} from '@nestjs/common';
11
import {FileInterceptor} from '@nestjs/platform-express';
12
import {AuthGuard} from '@nestjs/passport';
13
import {
14
  ApiUseTags,
15
  ApiBearerAuth,
16
  ApiOperation,
17
  ApiImplicitFile
18
} from '@nestjs/swagger';
19
import {ICommandBus} from 'src/Application/ICommandBus';
20
import {Roles} from 'src/Infrastructure/User/Decorator/Roles';
21
import {RolesGuard} from 'src/Infrastructure/User/Security/RolesGuard';
22
import {UserRole} from 'src/Domain/User/User.entity';
23
import {PayStubDTO} from '../DTO/PayStubDTO';
24
25
@Controller('pay_stubs')
26
@ApiUseTags('Accounting')
27
@ApiBearerAuth()
28
@UseGuards(AuthGuard('bearer'), RolesGuard)
29
export class CreatePayStubAction {
30
  constructor(
31
    @Inject('ICommandBus')
32
    private readonly commandBus: ICommandBus
33
  ) {}
34
35
  @Post()
36
  @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE)
37
  @UseInterceptors(FileInterceptor('file'))
38
  @ApiOperation({title: 'Create new paystub'})
39
  @ApiImplicitFile({
40
    name: 'file',
41
    required: true
42
  })
43
  public async index(@UploadedFile() file) {
44
    try {
45
    } catch (e) {
46
      throw new BadRequestException(e.message);
47
    }
48
  }
49
}
50